package gates;

import java.awt.Graphics;
import java.io.Serializable;


import master.*;

/**
 * An interface for the Quantum Gate :)
 *
 * @author Matthew
 * 
 * 01/03/13 Oliver: changed the actOnReg Method to allow specific bit operations 
 * 					also added the multiply method that can be implemented by complex gates to combine 2 smaller gates
 * 					this will break a lot of gates or they will have to be modified
 *
 */


public abstract class QuantumGate implements Serializable{

	public void actOnReg(QuantumRegister register){};
		
	public void draw(Graphics g, int x, int y , float scale){
		
		int [] vals = getActingBits();
		
		if(vals[0] == -1){
			g.drawRect(x, y-(int)(scale), (int)(scale), (int)(scale));
		}else{
			
			int largest = 0;
			for(int i = 0 ; i < getActingBits().length ; i++){
				if(largest < getActingBits()[i]) largest = getActingBits()[i];
			}
			int smallest = largest;
			for(int i = 0 ; i < getActingBits().length ; i++){
				if(smallest > getActingBits()[i]) smallest = getActingBits()[i];
			}
			
			for(int i = smallest ; i <= largest ; i++){
				g.drawRect(x, y+(int)(scale*Math.log(i)/Math.log(2)), (int)(scale), (int)(scale));
			}
			
		}
	};
	
	public int [] getActingBits(){return null;};//return an array of the qubits this gate acts on

	public static String getDescription(){return null;};

	public static String[] getConstructorDescription(){return null;};
	
}